<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<base href="<{$B_Url}>" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>登录</title> 
    <link rel="stylesheet" href="__PUBLIC__/index/css/kf.css" />
    <script type="text/javascript" src="__PUBLIC__/bootstrap/js/jquery.min.js"></script> 
    <script type="text/javascript" src="__PUBLIC__/index/js/jquery.form.js" ></script>
</head>
<body> 

<div>
	<form method="post" action="{:U('Login/register')}" id="register">
	手机号:<input type="tel" name="phone" id="verify_btn" required="required" />
	<input type="button" id="send" value="免费获取验证码" />  
	<br />
	<!-- 表单令牌验证 begin-->
	 <input type="hidden" value="{$arr}" id="token" name="token">
	<!-- 表单令牌验证 end-->
	 <input type="hidden" value="{$openid}"  name="openid" />
	验证码:<input type="text" name="verify" id="verify" /><br />
	称呼:<input type="radio" name="sex"  value="0"  checked="checked" />先生
		 <input type="radio" name="sex"    value="1" />女士<br />
	小区:<select form="register" name="plot" id="plot">
			<option>a</option>
			<option>b</option>
			<option>c</option>
		</select><br />
	<button type="button" onClick="checksubmit();">注册</button>
	</form>
</div>

</body>
</html>
<script type="text/javascript">
	function checksubmit(){
		
		var phone = $('#verify_btn').val();

		var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
			 if(!reg.test(phone)) 
	        { 
	           alert('请输入有效的手机号码!'); 
	       
	           return false; 
	       }

 		var v=$("#verify").val();
 		if (phone=="" || v=="") {
 			alert("手机号或者验证码不能为空");
 			return false;
 		};
 		var data={
 			phone:phone,
 			num:v,
 		}
 		$.post('{:U("Login/check")}',data,function(obj){
		if (obj.c=="shixiao") {
			alert(obj.m);
			return false;
		};
		if (obj.c=="error") {
			alert(obj.m);
			return false;
		};
		if (obj.c=="yes") {
			$('#register').submit();
		};
	});
	}

	var wait=60;  
	function time(o) {  
	        if (wait == 0) {  
	            o.removeAttribute("disabled");            
	            o.value="免费获取验证码";  
	            wait = 60;  
	        } else {  
	            o.setAttribute("disabled", true);  
	            o.value="重新发送(" + wait + ")";  
	            wait--;  
	            setTimeout(function() {  
	                time(o)  
	            },  
	            1000)  
	        }  
	    }  
	document.getElementById("send").onclick=function(){
		var phone=$('#verify_btn').val();
		var token=$('#token').val();
		var data={
			phone:phone,
			token:token,
			}
			var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
			 if(!reg.test(phone)) 
	        { 
	           alert('请输入有效的手机号码!'); 
	       
	           return false; 
	       }else{
	   		$.post('{:U("Login/msg")}',data,function(obj){
	  			if (obj.s=="no") {
	  				alert(obj.m);
	  			};
	  			if (obj.s=="ok") {
	  				alert(obj.m);
	  			};
	  			if (obj.s=="check") {
					alert(obj.m);
	  			};
	  			if (obj.s=="fail") {
	  				alert(obj.m);
	  			};
	      	});
			}

			time(this);

	} 
</script>